﻿/*----------------------------------------------------------------
//  <copyright file="IModuleRoleStore.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2022-11-16 16:14</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Authorization
{
    #region "定义模块角色信息存储"
    /// <summary>
    /// 定义模块角色信息存储
    /// </summary>
    public interface IModuleRoleStore<TModuleRole, in TRoleKey, TModuleKey>
    {
        #region "属性"
        #region "获取 模块角色信息查询数据集"
        /// <summary>
        /// 获取 模块角色信息查询数据集
        /// </summary>
        IQueryable<TModuleRole> ModuleRoles { get; }
        #endregion

        #endregion

        #region "方法"
        #region "检查模块角色信息是否存在"
        /// <summary>
        /// 检查模块角色信息是否存在
        /// </summary>
        /// <param name="predicate">检查谓语表达式</param>
        /// <param name="id">更新的模块角色信息编号</param>
        /// <returns>模块角色信息是否存在</returns>
        Task<bool> CheckModuleRoleExists(Expression<Func<TModuleRole, bool>> predicate, long id = default);
        #endregion
        #region "设置角色的可访问模块"
        /// <summary>
        /// 设置角色的可访问模块
        /// </summary>
        /// <param name="roleId">角色编号</param>
        /// <param name="moduleIds">要赋予的模块编号集合</param>
        /// <returns>业务操作结果</returns>
        Task<OperationResult> SetRoleModules(TRoleKey roleId, TModuleKey[] moduleIds);
        #endregion
        #region "获取角色可访问模块编号"
        /// <summary>
        /// 获取角色可访问模块编号
        /// </summary>
        /// <param name="roleId">角色编号</param>
        /// <returns>模块编号集合</returns>
        TModuleKey[] GetRoleModuleIds(TRoleKey roleId);
        #endregion

        #endregion

    }
    #endregion

}
